package com.sfa.action;

import com.sfa.services.LogService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * ajax调用获取控制台日志action
 * =============================================================
 * Version          Author          Date            Description
 * 1.0              白建         2017/11/8             创建
 * =============================================================
 */
@Controller
public class GetConsoleLog
{

    @RequestMapping(value = "/json", method = RequestMethod.GET)
    @ResponseBody
    public String getConsoleLogMethod(@RequestParam("port") String port, @RequestParam("server") String server)
    {

        LogService logService = new LogService();
        String out9080 = "/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/server1/SystemOut.log";
        String out9081 = "/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs/server1/SystemOut.log";
        //String outTest = "E:/SF0001144895A_MXServer_MaximoForSFA_Scheduled.log2017-06-16";

        if ("9080".equalsIgnoreCase(port))
        {
            return logService.readFileByLines(out9080);
        }
        else if ("9081".equalsIgnoreCase(port))
        {
            return logService.readFileByLines(out9081);
        }
        else
        {
            return "未找到相应日志，请联系管理员！";
        }
    }
}
